//
//  WoDeNavView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/27.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "WoDeNavView.h"

@implementation WoDeNavView
- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
        [self initOption];
    }
    return self;
}
- (void)initSubView{
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.titleLabel];
    [self addSubview:self.editeButton];
}
- (void)initOption{
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY);
        make.width.equalTo(@120);
        make.height.equalTo(@20);
    }];
    [_editeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-10);
        make.centerY.equalTo(self.mas_centerY);
        make.width.equalTo(@50);
        make.height.equalTo(@20);
    }];
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"账号信息";
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = [UIColor darkGrayColor];
        label.textAlignment = 1;
        _titleLabel = label;
    }
    return _titleLabel;
}
- (UIButton *)editeButton{
    if (!_editeButton) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"编辑" forState:UIControlStateNormal];
        [button setTitleColor:SELECTEDCOLOR forState:UIControlStateNormal];
        button.titleLabel.font  = [UIFont systemFontOfSize:13];
        [button addTarget:self action:@selector(editeClick:) forControlEvents:UIControlEventTouchUpInside];
        _editeButton =button;
    }
    return _editeButton;
}
- (void)editeClick:(UIButton *)sender{
    [self.delegate alertView];
}
- (void)drawRect:(CGRect)rect{
    UIBezierPath *path = [[UIBezierPath alloc]init];
    [path moveToPoint:CGPointMake(0, 49)];
    [path addLineToPoint:CGPointMake(self.frame.size.width, 49)];
    [LINCOLOR set];
    [path stroke];
}
@end
